<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="topic-table" class="topic-table"></div>
    <script src="../../jquery-1.8.0.js"></script>
    <script src="./topicTable.js"></script>
    <script>
        let data = [
            { topicName: '材料题12',topicType:'TOPIC_TYPE_CASE',difficulty:'DIFFICULT_TYPE_EASY',id:10},
            //{ topicName: '材料题-判断题-1',topicType:'TOPIC_TYPE_TRUE_FALSE',difficulty:'DIFFICULT_TYPE_EASY',parentId:10,id:11},
            { topicName: '材料题-单选-2',topicType:'TOPIC_TYPE_RADIO',difficulty:'DIFFICULT_TYPE_MIDDLE',parentId:10,id:12},
            { topicName: '材料题-单选-1',topicType:'TOPIC_TYPE_RADIO',difficulty:'DIFFICULT_TYPE_EASY',parentId:10,id:13},
            //{ topicName: '材料题-单选-4',topicType:'TOPIC_TYPE_RADIO',difficulty:'DIFFICULT_TYPE_DIFFICULT',parentId:10,id:14},
            { topicName: '材料题-单选-3',topicType:'TOPIC_TYPE_RADIO',difficulty:'DIFFICULT_TYPE_EASY',parentId:10,id:15},
            // { topicName: '多选题-1',topicType:'TOPIC_TYPE_MULTIPLE',difficulty:'DIFFICULT_TYPE_EASY',parentId:10,id:16},
            // { topicName: '多选题-2',topicType:'TOPIC_TYPE_MULTIPLE',difficulty:'DIFFICULT_TYPE_MIDDLE',parentId:10,id:17},
            // { topicName: '多选题-3',topicType:'TOPIC_TYPE_MULTIPLE',difficulty:'DIFFICULT_TYPE_EASY',parentId:10,id:18},
            // { topicName: '多选题-4',topicType:'TOPIC_TYPE_MULTIPLE',difficulty:'DIFFICULT_TYPE_MIDDLE',parentId:10,id:19},
            // { topicName: '简答题-1',topicType:'TOPIC_TYPE_ANSWER',difficulty:'DIFFICULT_TYPE_EASY',parentId:10,id:20},
            // { topicName: '简答题-2',topicType:'TOPIC_TYPE_ANSWER',difficulty:'DIFFICULT_TYPE_MIDDLE',parentId:10,id:21},
            
            { topicName: '单选2',topicType:'TOPIC_TYPE_RADIO',difficulty:'DIFFICULT_TYPE_MIDDLE',id:1},
            { topicName: '单选1',topicType:'TOPIC_TYPE_RADIO',difficulty:'DIFFICULT_TYPE_EASY',id:2},
            { topicName: '判断题3',topicType:'TOPIC_TYPE_TRUE_FALSE',difficulty:'DIFFICULT_TYPE_DIFFICULT',id:3},
            { topicName: '判断题4',topicType:'TOPIC_TYPE_TRUE_FALSE',difficulty:'DIFFICULT_TYPE_DIFFICULT',id:4},
            { topicName: '判断题2',topicType:'TOPIC_TYPE_TRUE_FALSE',difficulty:'DIFFICULT_TYPE_MIDDLE',id:5},
            { topicName: '判断题1',topicType:'TOPIC_TYPE_TRUE_FALSE',difficulty:'DIFFICULT_TYPE_EASY',id:6}
           
        ];

    
        //console.log(parSubTree(data));


        let inputData = [
                { topicType:'TOPIC_TYPE_RADIO',difficulty:'DIFFICULT_TYPE_MIDDLE',randomCount:1,topicScore:10.1,topicList:[1]},
                { topicType:'TOPIC_TYPE_RADIO',difficulty:'DIFFICULT_TYPE_EASY',randomCount:1,topicScore:1,topicList:[2]},
                { topicType:'TOPIC_TYPE_TRUE_FALSE',difficulty:'DIFFICULT_TYPE_DIFFICULT',randomCount:2,topicScore:10.5,topicList:[3,4]},
                { topicType:'TOPIC_TYPE_TRUE_FALSE',difficulty:'DIFFICULT_TYPE_MIDDLE',randomCount:1,topicScore:7.8,topicList:[5]},
                { topicType:'TOPIC_TYPE_TRUE_FALSE',difficulty:'DIFFICULT_TYPE_EASY',randomCount:1,topicScore:8,topicList:[6]},
                { topicType:'TOPIC_TYPE_RADIO',difficulty:'DIFFICULT_TYPE_MIDDLE',randomCount:1,topicScore:8,parentId:10,topicList:[12]},
                { topicType:'TOPIC_TYPE_RADIO',difficulty:'DIFFICULT_TYPE_EASY',randomCount:2,topicScore:10,parentId:10,topicList:[13,15]},
                // { topicName: '材料题12',topicType:'TOPIC_TYPE_CASE',difficulty:'DIFFICULT_TYPE_EASY',topicList:[
                // { topicName: '材料题-判断题-1',topicType:'TOPIC_TYPE_TRUE_FALSE',difficulty:'DIFFICULT_TYPE_EASY',randomCount:1,topicScore:2},
                // { topicName: '材料题-单选-2',topicType:'TOPIC_TYPE_RADIO',difficulty:'DIFFICULT_TYPE_MIDDLE',randomCount:1,topicScore:8},

                // { topicName: '材料题-单选-1',topicType:'TOPIC_TYPE_RADIO',difficulty:'DIFFICULT_TYPE_EASY',randomCount:2,topicScore:13},
                // { topicName: '材料题-单选-3',topicType:'TOPIC_TYPE_RADIO',difficulty:'DIFFICULT_TYPE_EASY',randomCount:2,topicScore:13},

                // { topicName: '材料题-单选-4',topicType:'TOPIC_TYPE_RADIO',difficulty:'DIFFICULT_TYPE_DIFFICULT',randomCount:1,topicScore:13},
                
                // { topicName: '多选题-1',topicType:'TOPIC_TYPE_MULTIPLE',difficulty:'DIFFICULT_TYPE_EASY',randomCount:2,topicScore:13},
                // { topicName: '多选题-2',topicType:'TOPIC_TYPE_MULTIPLE',difficulty:'DIFFICULT_TYPE_MIDDLE',randomCount:2,topicScore:13},
                // { topicName: '多选题-3',topicType:'TOPIC_TYPE_MULTIPLE',difficulty:'DIFFICULT_TYPE_EASY',randomCount:2,topicScore:13},
                // { topicName: '多选题-4',topicType:'TOPIC_TYPE_MULTIPLE',difficulty:'DIFFICULT_TYPE_MIDDLE',randomCount:2,topicScore:13},
                // { topicName: '简答题-1',topicType:'TOPIC_TYPE_ANSWER',difficulty:'DIFFICULT_TYPE_EASY',randomCount:1,topicScore:4},
                // { topicName: '简答题-2',topicType:'TOPIC_TYPE_ANSWER',difficulty:'DIFFICULT_TYPE_MIDDLE',randomCount:1,topicScore:4},
                // ],id:10}
            ]

        // let getInputData = function(settings){
        //     let inputData = [],parentIds = [];
        //     for(let i = 0; i < settings.length; i++){
        //         let setting = settings[i];
        //         if(setting.parentId && !(parentIds.indexOf(setting.parentId) > -1)){
        //             parentIds.push(setting.parentId);
        //             let topicCase = {topicId:setting.parentId,topicType:'TOPIC_TYPE_CASE'};
        //             inputData.push(topicCase);
        //         }
        //         for(let j = 0; j < setting.topicList.length; j++){
        //             let topicId = setting.topicList[j]
        //             , newSetting = $.extend({},setting);
        //             newSetting.topicId = topicId;
        //             delete newSetting.topicList;
        //             inputData.push(newSetting);
        //         }
        //     }
        //     return topicTable.utils.parSubTree(inputData,'parentId','topicId'); 
        // }

        //getInputData(inputData)

          
        //topicTable.utils.parSubTree(data)
        
        topicTable.render({
            data:data,
            inputData:inputData
        })

        let data2 = [
            // { topicName: '材料题12',topicType:'TOPIC_TYPE_CASE',difficulty:'DIFFICULT_TYPE_EASY',topicList:[
            //     { topicName: '材料题-判断题-1',topicType:'TOPIC_TYPE_TRUE_FALSE',difficulty:'DIFFICULT_TYPE_EASY'},
            //     { topicName: '材料题-单选-2',topicType:'TOPIC_TYPE_RADIO',difficulty:'DIFFICULT_TYPE_MIDDLE'},
            //     { topicName: '材料题-单选-1',topicType:'TOPIC_TYPE_RADIO',difficulty:'DIFFICULT_TYPE_EASY'},
            //     { topicName: '材料题-单选-4',topicType:'TOPIC_TYPE_RADIO',difficulty:'DIFFICULT_TYPE_DIFFICULT'},
            //     { topicName: '材料题-单选-3',topicType:'TOPIC_TYPE_RADIO',difficulty:'DIFFICULT_TYPE_EASY'},
            //     { topicName: '多选题-1',topicType:'TOPIC_TYPE_MULTIPLE',difficulty:'DIFFICULT_TYPE_EASY'},
            //     { topicName: '多选题-2',topicType:'TOPIC_TYPE_MULTIPLE',difficulty:'DIFFICULT_TYPE_MIDDLE'},
            //     { topicName: '多选题-3',topicType:'TOPIC_TYPE_MULTIPLE',difficulty:'DIFFICULT_TYPE_EASY'},
            //     { topicName: '多选题-4',topicType:'TOPIC_TYPE_MULTIPLE',difficulty:'DIFFICULT_TYPE_MIDDLE'},
            //     { topicName: '简答题-1',topicType:'TOPIC_TYPE_ANSWER',difficulty:'DIFFICULT_TYPE_EASY'},
            //     { topicName: '简答题-2',topicType:'TOPIC_TYPE_ANSWER',difficulty:'DIFFICULT_TYPE_MIDDLE'},
            // ],id:10},
            { topicName: '单选2',topicType:'TOPIC_TYPE_RADIO',difficulty:'DIFFICULT_TYPE_MIDDLE',id:1},
            { topicName: '单选1',topicType:'TOPIC_TYPE_RADIO',difficulty:'DIFFICULT_TYPE_EASY',id:2},
            { topicName: '判断题3',topicType:'TOPIC_TYPE_TRUE_FALSE',difficulty:'DIFFICULT_TYPE_DIFFICULT',id:3},
            { topicName: '判断题4',topicType:'TOPIC_TYPE_TRUE_FALSE',difficulty:'DIFFICULT_TYPE_DIFFICULT',id:4},
        ]

        // let ins = topicTable.render({
        //     data:data2,
        //     //inputData:inputData,
        //     //isDepOldIns:false
        // })
    </script>
</body>
</html>